<template>
  <div class="setting">
    <div class="setting-box">
      <div class="setting-header">设置</div>
      <el-form class="border-card" ref="form" label-position="left" :model="form" label-width="180px">
        <el-form-item label="头像">
          <!-- <el-avatar :size="160" src="https://empty" shape="square" @error="errorHandler">
            <img src="@/assets/common/portrait.jpeg" />
          </el-avatar> -->
          <head-image :name="form.name" :url="url"></head-image>

        </el-form-item>

        <el-form-item label="用户名">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="昵称">
          <el-input v-model="form.name"></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-radio v-model="form.sex" :label="0">男</el-radio>
          <el-radio v-model="form.sex" :label="1">女</el-radio>
        </el-form-item>

        <el-form-item label="清除聊天记录">
          <el-button type="primary">清除全部聊天记录</el-button>
        </el-form-item>
        <el-form-item label="存储位置">
          <el-input v-model="form.name" style="width: 250px; margin-right: 50px;"></el-input>
          <el-button type="primary">修改存储位置</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">修改</el-button>
          <el-button>清除</el-button>
        </el-form-item>
      </el-form>
    </div>

  </div>
</template>

<script>
import HeadImage from '../../components/HeadImage.vue';

export default {
  name: 'settingView',
  components: { HeadImage },

  data () {
    return {
      url: "",
      form: {}
    }
  },
  created () {
    this.init()
  },
  methods: {
    async init () {
      const data = await this.$http.post('/user/list', {
        token: sessionStorage.getItem('token'),
        pin: sessionStorage.getItem('userPin')
      })
      this.form = data.data.list[0]
      console.log(data.data.list, "data",this.form);
    },

  },

}
</script>

<style lang="scss" scoped>
.setting {
  width: 100%;
}

::v-deep.el-button {
  padding: 12px 18px !important;
}

::v-deep .el-tabs--border-card {
  border: 0px;
  box-shadow: none;
}

.setting-box {
  display: flex;
  flex-direction: column;

  .setting-header {
    padding: 3px;
    height: 60px;
    line-height: 60px;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    background-color: white;
    border-bottom: 1px #ddd solid;
  }

  .border-card {
    padding: 0px 20px;
    width: 700px;
  }
}
</style>